<template>
  <a-modal
    title="接口返回详情"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleCancel"
    @cancel="handleCancel"
    cancelText="关闭">

    <a-spin :spinning="confirmLoading">
      <a-form :form="form">

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="接口内容">
          <a-textarea :rows="15" :value="detailsData.responseText" readOnly/>
        </a-form-item>

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="接口类型">
          <a-input v-decorator="['logType_dictText', {}]" :readOnly="!!model.id"/>
        </a-form-item>

      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
  import {httpAction} from '@/api/manage'
  import pick from 'lodash.pick'
  import moment from "moment"

  export default {
    name: "LiteApiLogModalResponse",
    data() {
      return {
        title: "操作",
        visible: false,
        model: {},
        detailsData:{},
        labelCol: {
          xs: {span: 24},
          sm: {span: 5},
        },
        wrapperCol: {
          xs: {span: 24},
          sm: {span: 16},
        },

        confirmLoading: false,
        form: this.$form.createForm(this),
        validatorRules: {},
        url: {
          detailsUrl: "/log/liteApiLog/queryDetailsById"
        },
      }
    },
    created() {
    },
    methods: {
      details(record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model, 'logId', 'clientName', 'requestIp', 'requestUrl','logType_dictText', 'requestParam', 'responseText', 'logType', 'timeConsuming', 'errorMsg'))
          //时间格式化
        });
        httpAction(this.url.detailsUrl+'?id='+record.id+"&type=2", '', 'GET').then((res) => {
          console.info(res)
          if (res.success) {
            this.detailsData = res.result;
          }
        })
      },
      close() {
        this.$emit('close');
        this.visible = false;
      },
      handleOk() {
        this.close()
      },
      handleCancel() {
        this.close()
      },
    }
  }
</script>

<style lang="less" scoped>

</style>